<?php
	include('header.php');
?>
		<!--[if !IE]>start content<![endif]-->
		<div id="content">
			<div class="inner">
				<!--[if !IE]>start section<![endif]-->
				<?php
					if(isset($_POST['reset'])){
						$_POST	= "";
					}
					if(isset($_POST['daftar'])){
						if(empty($_POST['noplate'])){
							$errors[] = 'Please insert plate no.';
						}
						
						if(is_array($errors)){
							echo"
								<div class='section'>
									<ul class='system_messages'>
									<li class='yellow'><span class='ico'></span>
										<strong class='system_title'>Amaran!</strong>";
							while (list($key,$value) = each($errors))
							{
									echo "<br/><span class='system_title'>".$value."</span>";
							}
							echo "	</li>
									</ul>
								</div>";
						}else{
							
							$noplate = strtoupper(mysql_real_escape_string($_POST['noplate'])); 
							
							$Qnoic = "SELECT count(*) from transport where trn_plate_no = '$noplate'";
							$Tnoic= $db->sql_total($Qnoic);	
							
								
							
							if($Tnoic <> 0){
								echo"
										<div class='section'>
											<ul class='system_messages'>
												<li class='yellow'><span class='ico'></span><strong class='system_title'>Identity No. not available!</strong> </li>
											</ul>
										</div>";
							}
							
							if($Tnoic==0 ){
								$createUser= "INSERT INTO transport (trn_plate_no, trn_created_date, trn_created_by) VALUES 
								('$noplate',NOW(),'$_SESSION[log_userlogin_id]')";
								$result = $db->sql_query($createUser);
								
								if ($result){	
									//	Display success																			
									echo'
									<div class="section">
										<ul class="system_messages">
											<li class="green"><span class="ico"></span><strong class="system_title">Success Added Transport!</strong></li>
										</ul>
									</div>
										';
								}
							}
							
						}
					
					}
				
				?>
				<!--[if !IE]>end section<![endif]-->
				
				<!--[if !IE]>start section<![endif]-->
				<div class="section">
					
					<!--[if !IE]>start title wrapper<![endif]-->
					<div class="title_wrapper">
						<span class="title_wrapper_top"></span>
						<div class="title_wrapper_inner">
							<span class="title_wrapper_middle"></span>
							<div class="title_wrapper_content">
								<h2>Add Transport</h2>
							</div>
						</div>
						<span class="title_wrapper_bottom"></span>
					</div>
					<!--[if !IE]>end title wrapper<![endif]-->
					
					<!--[if !IE]>start section content<![endif]-->
					<div class="section_content">
						<span class="section_content_top"></span>
						
						<div class="section_content_inner">
						
						
						<!--[if !IE]>start forms<![endif]-->

						<form action="" method="POST" class="search_form general_form">
							<!--[if !IE]>start fieldset<![endif]-->
							<fieldset>
								<!--[if !IE]>start forms<![endif]-->
								<div class="forms">
								<!--[if !IE]>start row<![endif]-->
								<div class="row">
									<label>Plate No. :</label>
									<div class="inputs">
										<span class="input_wrapper" style="width:300px;"><input name="noplate" class="text" value="<?php if($_POST['noplate'] != "") echo $_POST['noplate'] ?>" type="text" /></span>
									</div>
								</div>
								<!--[if !IE]>end row<![endif]-->
								
								<!--[if !IE]>start row<![endif]-->
								<div class="row">
									<div class="inputs">
										<span class="button green_button"><span><span>ADD</span></span><input name="daftar" type="submit" /></span>
										<span class="button gray_button"><span><span>RESET</span></span><a href="transportadd.php" ><input name="reset" type="submit" /></a></span> 
									</div>
								</div>
								<!--[if !IE]>end row<![endif]-->
								
								
								
								</div>
								<!--[if !IE]>end forms<![endif]-->
								
								</fieldset>
							<!--[if !IE]>end fieldset<![endif]-->
						</form>
						
						<!--[if !IE]>end forms<![endif]-->
						
						</div>
						
						<span class="section_content_bottom"></span>
					</div>
					<!--[if !IE]>end section content<![endif]-->
				</div>
				<!--[if !IE]>end section<![endif]-->
				
				
				
				
				
				
					
				
			</div>
		</div>
		<!--[if !IE]>end content<![endif]-->

<?php
	include('footer.php');
?>